-
Notifications
You must be signed in to change notification settings - Fork 48
Avoid silently wrong results on 10bit CUDA #777
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
// AVFrame is on GPU memory. It can be on CPU memory if the video isn't | ||
// supported by NVDEC for whatever reason: NVDEC falls back to CPU decoding in | ||
// this case, and our check fails. | ||
// TODO: we could send the frame back into the CPU path, and rely on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's create an issue to track.
|
||
AVPixelFormat actualFormat = | ||
reinterpret_cast<AVHWFramesContext*>(avFrame->hw_frames_ctx->data) | ||
->sw_format; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got tripped up reading this because I'm not used to seeing a reinterpret_cast
inside of an expression. I think it's easier to read as:
hwFramesCtx = reinterpret_cast<AVHWFramesContext*>(avFrame->hw_frames_ctx->data);
AVPixelFormat actualFormat = hwFramesCtx->sw_format;
Also: TIL that AVBufferRef*
is effectively Object*
for FFmpeg, and they use it to store lots of different generic stuff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, great catch!
@pytest.mark.parametrize("asset", (H264_10BITS, H265_10BITS)) | ||
def test_10bit_videos_cpu(self, asset): | ||
# This just validates that we can decode 10-bit videos on CPU. | ||
# TODO validate against the ref that the decoded frames are correct |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is required to test that the decoded frames are correct? It seems we would need to check in additional png files from each 10-bit video to the test/resources/
, are there other changes needed?
Addresses #736 and #598.
Some 10bit videos are properly decoded by NVDEC, but are passed as-is to the NPP color conversion functions, which expect 8bits videos. This results in garbage output. This PR adds a check to prevent such incorrect conversion. It does not add support for 10 bit videos on CUDA. It just avoids silently wrong results.